『What every systems programmer should know about concurrency』Matt Kline
Matt Kline. What every systems programmer should know about concurrency. 2020
Abstract
Systems programmers are familiar with tools like mutexes, semaphores, and condition variables. But how do they work? How do we write concurrent code when they’re not available, like when we’re working below the operating system in an embedded environment, or when we can’t block due to hard time constraints? And since your compiler and hardware conspire to turn your code into things you didn’t write, running in orders you never asked for, how do multithreaded programs work at all? Concurrency is a complicated and unintuitive topic, but let’s try to cover some fundamentals.
↓
システムプログラマーはミューテックス、セマフォ、条件変数といったツールに精通している。しかしそれらはどのように機能するのか? これらを利用できない環境、例えば組み込み環境でOSの下位層を扱う場合や、厳しい時間制約でブロックできない状況では、並行コードをどう記述すればよいのか?さらに、コンパイラとハードウェアが共謀してコードを意図しない形に変換し、要求していない順序で実行される中で、マルチスレッドプログラムは一体どうやって動作しているのか?並行処理は複雑で直感に反するテーマだが、その基礎をいくつか見ていこう。
table:目次
1. Background 背景 2
2. Enforcing law and order 法と秩序の強制 3
3. Atomicity アトミック性 3
4. Arbitrarily-sized "atomic" types 任意サイズの「アトミック」型 3
5. Read-modify-write 読み取り-変更-書き込み 4
5.1. Exchange 交換 4
5.2. Test and set テストアンドセット 4
5.3. Fetch and… フェッチと… 4
5.4. Compare and swap 比較とスワップ 4
6. Atomic operations as building blocks 構成要素としてのアトミック操作 5
7. Sequential consistency on weakly-ordered hardware 弱順序ハードウェアにおける逐次一貫性 5
8. Implementing atomic read-modify-write operations LL/SC命令によるアトミック 6
with LL/SC instructions 読み取り-変更-書き込み操作の実装
8.1. Spurious LL/SC failures 偽のLL/SC失敗 6
9. Do we always need sequentially consistent operations? 常に逐次一貫性のある操作が必要か? 6
10. Memory orderings メモリ順序 7 10.1. Acquire and release 取得と解放 7
10.2. Relaxed 緩和 8
10.3. Acquire-Release 取得-解放 8
10.4. Consume 消費 9
10.5. hc svnt dracones ここに竜あり 10
11. Hardware convergence ハードウェアの収束 10
12. Cache effects and false sharing キャッシュ効果と偽共有 10
13. If concurrency is the question, volatile is not the answer. 並行性が問題なら、volatileは答えではない 10
14. Atomic fusion アトミック融合 11
15. Takeaways 要点 11
Additional Resources 追加リソース 12
Contributing 貢献 12
Colophon 奥付 12